def edit_fluid(window_fluid):
    data_fluid = {'name': None,
                  'mass_flow': None,
                  'density': None,
                  'dynamic_viscosity': None
                  }

    for key, value in zip(data_fluid, window_fluid.get_property_fluid()):
        data_fluid[key] = value.replace(',', '.')

    return data_fluid


def view_fluid_data(main_window, data_fluid):
    main_window.fluidname.setText(data_fluid.get('name', None))
    main_window.value_density.setText(data_fluid.get('density', None))
    main_window.value_viscos.setText(data_fluid.get('dynamic_viscosity', None))
    main_window.value_massflow.setText(data_fluid.get('mass_flow', None))


def except_fluid_data(dct_for_checking: dict, window_fluid):
    string_errors = []

    for key, value, string_error in zip(dct_for_checking.keys(),
                                        dct_for_checking.values(),
                                        window_fluid.get_name_property_fluid()):

        if key == 'name' and value == '':
            string_errors.append(string_error.objectName())
            continue
        elif key != 'name':
            value = value.replace(',', '.')
            try:
                float(value)
            except ValueError:
                string_errors.append(string_error.objectName())
                continue
            if '.' not in value and value[0] == '0':
                string_errors.append(string_error.objectName())
                continue
            elif value[0] == '-':
                string_errors.append(string_error.objectName())
                continue
            elif all(char == '0' for char in value.replace('.', '0')):
                string_errors.append(string_error.objectName())
                continue

    return string_errors


def raise_exception(string_errors: list):
    if len(string_errors) > 0:
        raise ValueError



